package com.mall.admin.controller;

import com.mall.admin.service.UmsMenuService;
import com.mall.commons.utils.R;
import com.mall.domain.UmsMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/menu")
public class UmsMenuController {
    @Autowired
    private UmsMenuService umsMenuService;
    @PostMapping("/create")
    public R  save(@RequestBody UmsMenu umsMenu){
       return umsMenuService.save(umsMenu);
    }
    @PostMapping("/delete/{id}")
    public R delete(@PathVariable Integer id){
       return umsMenuService.delete(id);
    }
    @GetMapping("list/{parentId}")
    public R list(Integer pageNum,Integer pageSize,@PathVariable Integer parentId){
      return  umsMenuService.list(pageNum, pageSize, parentId);
    }
    @GetMapping("/treeList")
    public R listTree(){
     return  umsMenuService.listTree();
    }
    @PostMapping("/update/{id}")
    public R update(@PathVariable Integer id,@RequestBody UmsMenu umsMenu){
        return umsMenuService.update(id,umsMenu);
    }
    @PostMapping("updateHidden/{id}")
    public R updateHidden(Integer hidden,@PathVariable Integer id){
        return umsMenuService.updateHidden(hidden,id);
    }
    @GetMapping("/{id}")
    public R get(@PathVariable Integer id){
        return umsMenuService.get(id);
    }

}
